var t = getApp();

Page({
    data: {
        language: "",
        cash: "",
        integral: 0,
        name: "",
        isclick: !0
    },
    onLoad: function(t) {
        this.getName(), this.getData();
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {
        this.data.isclick = !0;
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getName: function() {
        var a = this, e = t.getNetAddresss("plugin.integral.Frontend.Controllers.page.get-name");
        t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 === e.result ? a.setData({
                    name: e.data
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.integral.Frontend.Controllers.Page.index");
        t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 === e.result ? a.setData({
                    integral: e.data.member_integral,
                    cash: ""
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    sureCash: function() {
        var a = this;
        if (this.data.isclick) {
            if (this.data.isclick = !1, !this.data.cash) return wx.showToast({
                title: "请输入提现数额",
                icon: "none"
            }), void (this.data.isclick = !0);
            if (Number(this.data.cash) > Number(this.data.integral)) return wx.showToast({
                title: "输入的提现数额超过已有的" + this.data.name,
                icon: "none"
            }), void (this.data.isclick = !0);
            var e = t.getNetAddresss("plugin.integral.Frontend.Modules.Integral.Controllers.Withdraw");
            e += "&change_value=" + this.data.cash, t._getNetWork({
                url: e,
                success: function(t) {
                    console.log(t, "数据"), 1 === t.data.result ? (a.getData(), wx.navigateTo({
                        url: "/packageA/member/withdrawal/withdrawal"
                    })) : (a.data.isclick = !0, wx.showToast({
                        title: t.data.msg,
                        icon: "none"
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else wx.showToast({
            title: "请勿重复点击",
            icon: "none"
        });
    },
    onChange: function(t) {
        this.setData({
            cash: t.detail
        });
    }
});